<?php

function load_js_validate() {
    echo "\n <script src=\"" . URLHOST . "asset/js/validate.js\" type=\"text/javascript\"></script>";
}

function load_js_validate_email() {
    echo "\n <script src=\"" . URLHOST . "asset/js/validate_email.js\" type=\"text/javascript\"></script>";
}

function load_jquery_update() {
    ?>
    <script type="text/javascript" src="<?php echo URLHOST ?>asset/js/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(function()
        {
            // a href tag
            $("a").click(function()
            {
                var titleid = $(this).attr("id");
                var sid=titleid.split("edit"); // Splitting eg: title21 to 21
                var id=sid[1];
                var parent = $(this).parent();
                $(this).hide();
                $("#formbox"+id).show();
                return false;
            });
            
            // Cancel Button
            $(".cancel").click(function()
            {
                var A=$(this).parent().parent();
                var X= A.attr("id");
                var d=X.split("formbox");
                var id=d[1];
                $("#edit"+id).show();
                A.hide();
                return false;
            });

        });
    </script>
    <?php
}

function load_tinymce() {
    ?>
    <!-- TinyMCE -->
    <script type="text/javascript" src="<?php echo URLHOST ?>asset/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript" src="<?php echo URLHOST ?>asset/tiny_mce/plugins/ajaxfilemanager/jscripts/general.js"></script>
    <script type="text/javascript">
        tinyMCE.init({
            mode : "textareas",
            elements : "ajaxfilemanager",
            theme : "advanced",
            plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordpress",
                                                                				
                                                                                                
            // Theme options
            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,bullist,numlist,|,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect,fontsizeselect|,wp_more,wp_adv",
            theme_advanced_buttons2 : "link,unlink,image,media,|,forecolor,|,pastetext,pasteword,|,hr,removeformat,|,undo,redo,|,emotions,|,fullscreen,preview,help,code",
            theme_advanced_buttons3 : "", //"|,sub,sup,|,charmapiespelladvhr,|,print,|,ltr,rtl,|,visualchars,nonbreaking,template,pagebreak,|,",
            theme_advanced_buttons4 : "", //tablecontrols,|,forecolor,backcolor,|,cite,abbr,acronym",
                                                                            
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resize_horizontal : false,
            theme_advanced_resizing : true,
            file_browser_callback : "ajaxfilemanager",
                                                                                                
                                                                            
                                                                                                
            // Example content CSS (should be your site CSS)
            content_css : "<?php echo URLHOST; ?>asset/css/wp.css"
        });

        function ajaxfilemanager(field_name, url, type, win) {
            var ajaxfilemanagerurl = "../ajaxfilemanager/ajaxfilemanager.php";
            switch (type) {
                case "image":
                    break;
                case "media":
                    break;
                case "flash": 
                    break;
                case "file":
                    break;
                default:
                    return false;
            }
            tinyMCE.activeEditor.windowManager.open({
                url: "../ajaxfilemanager/ajaxfilemanager.php",
                width: 782,
                height: 440,
                inline : "yes",
                close_previous : "no"
            },{
                window : win,
                input : field_name
            });
        }
    </script>
    <!-- /TinyMCE -->
    <?php
}
?>
